﻿package com.wxsoft.business.physic.service.impl;

import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.wxsoft.business.model.easyui.PageHelper;
import com.wxsoft.business.physic.dao.IPsPhysicPriceModifyHeadDao;
import com.wxsoft.business.physic.pojo.PsPhysicInHead;
import com.wxsoft.business.physic.pojo.PsPhysicPriceModifyDetail;
import com.wxsoft.business.physic.pojo.PsPhysicPriceModifyHead;
import com.wxsoft.business.physic.service.IPsPhysicPriceModifyService;
import com.wxsoft.util.wx.UUIDUtil;

@Service("psPhysicPriceModifyService")
public class PsPhysicPriceModifyServiceImpl implements IPsPhysicPriceModifyService  {
	@Resource
	private IPsPhysicPriceModifyHeadDao dao;
	
	
	public long findCount(PsPhysicPriceModifyHead psPhysicPriceModifyHead) {
		return dao.findCount(psPhysicPriceModifyHead);
	}
	
	public List<PsPhysicPriceModifyHead> findAll(PageHelper page,PsPhysicPriceModifyHead psPhysicPriceModifyHead) {
        List<PsPhysicPriceModifyHead> r = dao.findAll(page,psPhysicPriceModifyHead);
		return r;
	}
	@Transactional
	public String add(PsPhysicPriceModifyHead psPhysicPriceModifyHead) {
		
		psPhysicPriceModifyHead.setAccount_sign("no");
		
		int r = this.dao.insert(psPhysicPriceModifyHead);
		if(r==1){
			return "操作成功!";
		}
		return "操作失败!";
	}
	@Transactional
	public String modify(PsPhysicPriceModifyHead psPhysicPriceModifyHead) {
		int r = this.dao.modify(psPhysicPriceModifyHead);
		if(r==1){
			return "操作成功!";
		}
		return "操作失败!";
	}
	@Transactional
	public String delete(PsPhysicPriceModifyHead psPhysicPriceModifyHead) {
		int r = this.dao.delete(psPhysicPriceModifyHead);
		if(r==1){
			return "操作成功!";
		}
		return "操作失败!";
	}
	/**
	 * 增加调价消息
	 * @Description:TODO
	 * @author: chenliang
	 * @time:2018-4-2 下午2:35:19
	 */
	@Transactional
	public String add(PsPhysicPriceModifyHead psPhysicPriceModifyHead,
			List<PsPhysicPriceModifyDetail> ppidForI, List<PsPhysicPriceModifyDetail> ppidForU,
			List<PsPhysicPriceModifyDetail> ppidForD){
		//判断 是否存在 此单据号
		
		//默认没有记账
		//保存头
		psPhysicPriceModifyHead.setAccount_sign("no");
		int r = this.dao.insert(psPhysicPriceModifyHead);
		if(r==1){
			return "操作成功!";
		}
		
		//保存明细
		
		
		return "";
	}
	/**
	 * 修改价格调整 
	 * @Description:TODO
	 * @author: chenliang
	 * @time:2018-4-2 下午2:39:38
	 */
	@Transactional
	public String modify(PsPhysicPriceModifyHead psPhysicPriceModifyHead,
			List<PsPhysicPriceModifyDetail> ppidForI, List<PsPhysicPriceModifyDetail> ppidForU,
			List<PsPhysicPriceModifyDetail> ppidForD){
		//判断要修改的记录是否已 审核记账
		
		//执行修改操作
		int r = this.dao.modify(psPhysicPriceModifyHead);
		if(r!=1){
			throw new RuntimeException("操作失败!");
		}
		//保存明细
		
		
		return "";
	}
	
}
